package com.dgw.controller;

import com.dgw.domain.User;
import com.dgw.services.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: SSM-Vue
 * @description:
 * @author: Mr.Dai
 * @create: 2019-12-21 11:29
 **/
@Controller
@RequestMapping("/user")
@ResponseBody
public class UserController {

    private IUserService iUserService;

    @Autowired
    public void setiUserService(IUserService iUserService) {
        this.iUserService = iUserService;
    }

    @GetMapping("/findAll")
    public List<User> findALL(){
        return  iUserService.findALL();
    }
    @GetMapping("/findUserById")
    public User findUserById(@RequestParam("userid") Integer id){
        return  iUserService.findUserById(id);
    }
    @PostMapping("/updateUser")
    public void updateUser(@RequestBody User user){
        System.out.println(user);
        iUserService.updateUser(user);
    }

    @GetMapping("/findId/{id}")
    public String testALl(@PathVariable("id") Integer id){
        System.out.println("test");
        return iUserService.findUserById(1).toString();
    }
}
